package com.soccertgc.core.game.events 
{
	
	import com.soccertgc.core.game.Game;
	
	import flash.events.Event;

	public class GameEvent extends Event
	{
		
		// -------------------------------------------------------------------------------
		// CONSTANTS
		// -------------------------------------------------------------------------------	
		
		// Events
		public static const         EVENT_GAME_CHANGED:String						= "gameChanged";
		public static const         EVENT_GAME_STATUS_CHANGED:String				= "gameStatusChanged";
		public static const         EVENT_GAME_START:String							= "gameStart";						// game started
		public static const         EVENT_GAME_RESTART:String						= "gameRestart";					// game restarted
		public static const         EVENT_GAME_SUBSTITUTION_PHASE:String			= "gameSubstitutionPhase";			// turn > fase sostituzione giocatori
		public static const         EVENT_GAME_RESOLVE_SUBSTITUTION_PHASE:String	= "gameResolveSubstitutionPhase";	// turn > risoluzione fase Substitution
		public static const         EVENT_GAME_DISCARD_PHASE:String					= "gameDiscardPhase";				// turn > fase scarto carte
		public static const         EVENT_GAME_RESOLVE_DISCARD_PHASE:String			= "gameResolveDiscardPhase";		// turn > risoluzione fase Discard
		public static const         EVENT_GAME_PLAY_PHASE:String					= "gamePlayPhase";					// turn > fase scelta azione e gioco carte
		public static const         EVENT_GAME_RESOLVE_PLAY_PHASE:String			= "gameResolvePlayPhase";			// turn > risoluzione fase Play
		public static const         EVENT_GAME_RESYNC_PHASE:String					= "gameResyncPhase";				// turn > fase risoluzione
		public static const         EVENT_GAME_NEXT_TURN:String						= "gameNextTurn";
		public static const         EVENT_GAME_NEXT_TURN_PHASE:String				= "gameNextTurnPhase";
		public static const         EVENT_GAME_RESYNC:String						= "gameResync";						// game full resync after desync
		public static const         EVENT_GAME_END:String							= "gameEnd";						// game ended
		public static const         EVENT_GAME_DESYNC:String						= "gameDesync";						// game desync from server
	
		public static const         EVENT_GAME_PHASE_TIMEOUT:String					= "gamePhaseTimeout";				// phase > 
		public static const         EVENT_GAME_PHASE_PROGRESS:String				= "gamePhaseProgress";				// phase > 
		public static const         EVENT_GAME_PHASE_ERROR:String					= "gamePhaseError";					// phase > 
		
		public static const         EVENT_GAME_ERROR:String							= "gameError";						// game unexpected error
		
		// -------------------------------------------------------------------------------
		// FIELDS
		// -------------------------------------------------------------------------------
		
		private var _game:Game;

		// -------------------------------------------------------------------------------
		// CONSTRUCTOR
		// -------------------------------------------------------------------------------
		
		/**
		 * Creates a new generic GameEvent
		 * @param t Type of the event
		 * @param g Game reference that dispatched the event
		 */		
		public function GameEvent(t:String, g:Game)
		{
			// ancestor constructor
			super(t); 
			// Initialization
			_game = g;
		}
		
		// -------------------------------------------------------------------------------
		// PROPERTIES
		// -------------------------------------------------------------------------------

		public function get game():Game
		{
			return _game;
		}

	}
}